<template>
  <div id="Rule">
    <body-container>
      <vj-form @submit="onSubmit" :loading="loading" class="vj-form" :cfg-list="cfgList" :form-data.sync="formData"/>
    </body-container>
  </div>
</template>
<script lang="ts">
import Vue, {ComponentOptions, VueConstructor} from "vue"
import Component from 'vue-class-component'
import BodyContainer from "@/components/layout/body-container.vue";
import {AboutFM, RuleFM} from "@/config/form";
import {hookSubmit} from "vijay-util";
import {requestByGet, requestByPost, requestByPut} from "@/utils/request";
import {Mixins} from "vue-property-decorator";
import {FormMixin} from "@/plugins/mixins/form";

export const title = ""
@Component({
  components: {BodyContainer}
})
export default class Rule extends Mixins(FormMixin) implements ComponentOptions<Vue> {
  name = "Rule"
  cfgList = RuleFM;
  formData = {};
  editId = null;

  @hookSubmit()
  async onSubmit() {
    const requestFn = this.editId ? requestByPut : requestByPost;
    await requestFn(`qqc/qqcQualification/${this.editId ? 'edit' : 'add'}`, {...this.formData, id: this.editId});
    this.$message.success("操作成功！");
    location.reload();
  }

  async onSearch() {
    const data = await requestByGet('qqc/qqcQualification/queryById', {id: 1});
    if (!data) return;
    this.formData = data
    this.editId = data.id
  }

  created() {
    this.onSearch();
  }
}
</script>

<style scoped lang="scss">
@import "~assets/common.scss";

#Rule {
}
</style>
